package com.complex.spring.advance.aop.base;

import java.lang.annotation.Target;

import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.ControlFlowPointcut;
import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.aop.support.NameMatchMethodPointcut;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;

public class PointcutTest {
	public static void main(String[] args) {
		//匹配方法名称,可以使用通配符 *
		NameMatchMethodPointcut npointcut = new NameMatchMethodPointcut();
		npointcut.setMappedNames(new String[]{"",""});
		
		//匹配JDK的正则表达式
		JdkRegexpMethodPointcut jpointcut = new JdkRegexpMethodPointcut();
		jpointcut.setPatterns(new String[]{"",""});
		
		//需要引入jakarta oro,匹配其提供的正则表达式
		//Perl5RegexpMethodPointcut ppointcut = new Perl5RegexpMethodPointcut();
		
		//匹配特定的annotation
		AnnotationMatchingPointcut apointcut = new AnnotationMatchingPointcut(Target.class);
		
		//进行pointcut逻辑运算,支持并和交    也可以使用Pointcuts工具类
		ComposablePointcut cpointcut = new ComposablePointcut();
		cpointcut.union(new AnnotationMatchingPointcut(Target.class));//并
		cpointcut.intersection(new AnnotationMatchingPointcut(Target.class));//交
		
		//只在PointcutTest类中织入相应代码
		ControlFlowPointcut cfpointcut = new ControlFlowPointcut(PointcutTest.class);
		
	}
}
